#include "eventfilter.h"
#include <qevent.h>
#include <qmessagebox.h>
#include <qlineedit.h>


eventfilter::eventfilter(QWidget *parent)
	: QDialog(parent)
{
	pLineEdit = new QLineEdit(this);
	pLineEdit->setText("LineEdit");
	
	pLineEdit->installEventFilter(this);
}

eventfilter::~eventfilter()
{

}

void eventfilter::keyPressEvent(QKeyEvent * event)
{
	if(event->key() == Qt::Key_Space)
	{
		QMessageBox::information(this,tr("information"),tr("key space"));
    }
	else
	{
        QWidget::keyPressEvent(event);
	}
}

bool eventfilter::eventFilter(QObject * o, QEvent * e)
{
	if(o == pLineEdit)
	{
		if(e->type() == QEvent::KeyPress)
			QMessageBox::information(this,tr("information"),tr("LineEdit eventfilter"));
	}
    return QWidget::eventFilter(o,e);
}
